﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace finProj.Entities
{
    class PictureManager
    {
        public Picture[] pic;
        public List<Picture> Pictures;
        public Canny[] EdgesPic;
        //public FeatureVector[] featureVectors;

        public PictureManager()
        {
            Pictures = new List<Picture>();

        }

        public PictureManager(Picture[] PicList)
        {
            int n = PicList.Length;
            this.pic = new Picture[n];// creating array of original picture
            PicList.CopyTo(pic, n);

            for (int i = 0; i < n; i++)//creating array of canny picture
            {
                this.EdgesPic[i] = new Canny(PicList[i]);
            }

            for (int i = 0; i < n; i++)//creating array of feature vectors
            {
                //this.vec[i] = new FeatureVector(this.EdgesPic[i]);
            }
        }
        public void AddPicture(Picture p)
        {

            Pictures.Add(p);
            // int size = this.pic.Length;

            // //////////////////////////////////////////////////////////resize picture array//////////////////////////
            // Picture[] tempPic = new Picture[size];
            // this.pic.CopyTo(tempPic, size);     //copying to temp array
            // this.pic = new Picture[size + 1];   //resize array
            // tempPic.CopyTo(this.pic, size);
            // this.pic[size + 1] = p;             //add new picure to picture array

            // //////////////////////////////////////////////////////////resize canny array/////////////////////////////
            // Canny[] tempCanny = new Canny[size];
            // this.EdgesPic.CopyTo(tempCanny, size);
            // this.EdgesPic = new Canny[size + 1];
            // tempCanny.CopyTo(this.EdgesPic, size);
            // Canny temp = new Canny(p);
            // this.EdgesPic[size + 1] = temp;


            // //////////////////////////////////////////////////////////////resize of feature vectors array/////////////////
            // FeatureVector[] tempFeatureVec = new FeatureVector[size];
            // this.vec.CopyTo(tempFeatureVec, size);
            // this.vec = new FeatureVector[size + 1];
            // tempFeatureVec.CopyTo(vec, size);
            //// FeatureVector tempV = new FeatureVector(EdgesPic[size + 1]);
            //// this.vec[size + 1] = tempV;

        }
        public void AddExistingKeys()
        {
            var map = new Dictionary<string, int>();
            foreach (var picture in Pictures)
            {
                foreach (KeyValuePair<string,double> i in picture.FeaturesVec.features)
                {
                    if (! map.ContainsKey(i.Key))
                    {
                        map.Add(i.Key, 1);
                        Settings.Instance.existingKeys.Add(i.Key);
                    }
                }
            }


        }

       

    }
}